package com.xm.xmapp;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.xm.xmapp.adapter.ListUserTimeAdapter;
import com.xm.xmapp.app.CodeConstant;
import com.xm.xmapp.base.BaseActivity;
import com.xm.xmapp.customview.XListView;
import com.xm.xmapp.response.bean.CustomItemTextBean;
import com.xm.xmapp.response.bean.ResponseBankListBean;

public class BankSelectActivity extends BaseActivity {
	private XListView xListView;
	private ListUserTimeAdapter adapter;
	private ArrayList<CustomItemTextBean> list;
	private ResponseBankListBean bean;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_list);
	}

	@Override
	public void initView() {
		xListView = (XListView) findViewById(R.id.xListView);
	}

	@Override
	public void initData() {

		setMyTitle("选择银行");
		bean = (ResponseBankListBean) getIntent().getSerializableExtra("bean");
		list = new ArrayList<CustomItemTextBean>();
		list.addAll(bean.list);
		adapter = new ListUserTimeAdapter(list, this, R.layout.item_listactivity);
		xListView.setAdapter(adapter);
		xListView.setPullRefreshEnable(false);
		xListView.setPullLoadEnable(false);

	}

	@Override
	public void initEvent() {
		xListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				intent = getIntent();
				intent.putExtra("bean", list.get(position - 1));
				setResult(CodeConstant.BankCode, intent);
				finish();
			}
		});
	}

}
